package com.czxy.changgou3.com.czxy.changgou3.mapper;

import com.czxy.changgou3.pojo.Brand;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author zhangmengxiang1@itcast.cn
 * @version 1.0
 * @date 2020/4/22
 */
@org.apache.ibatis.annotations.Mapper
public interface BrandMapper extends Mapper<Brand> {

    /**
     * 根据指定分类id查询所有的品牌
     * @param categoryId
     * @return
     */
    @Select("select b.* from tb_brand b ,tb_category_brand cb where b.id = cb.brand_id and cb.category_id = #{categoryId}")
    @Results({
            @Result(property = "id",column = "id"),
            @Result(property = "brandName",column = "brand_name"),
            @Result(property = "logo",column = "logo"),
    })
    public List<Brand> findAll(@Param("categoryId") Integer categoryId);

}
